@echo off
for /f "tokens=1-3 delims=-/ " %%1 in ("%date%") do set ddd=%%1%%2%%3
for /f "tokens=1-4 delims=.: " %%1 in ("%time%") do set tttt=%%1%%2%%3%%4
set DT=%ddd%%tttt%
echo %DT%
for /f %%i in (ipconf.txt) do (
	echo %%i
	if exist %~dp0target\%%i (
	echo Error: Directory already exists
	rem del /s /q %saveDir%
	goto end
	) else (
	mkdir %~dp0target\%%i
	)
	
	keytool -validity 36500 -genkey -v -alias server -keyalg RSA -keystore %~dp0target\%%i\server.keystore -dname "CN=%%i,OU=sss,O=sss,L=BeiJing,ST=BeiJing,c=cn" -storepass 123456 -keypass 123456 -ext san=ip:%%i
	keytool -export -v -alias server -keystore %~dp0target\%%i\server.keystore -storepass 123456 -rfc -file %~dp0target\%%i\server.cer
)
:end
pause
